import axios, {ResponseData} from 'yuxin-base/src/utils/axios'

// 绑定门禁设备
export function bindAccess(data: object): Promise<ResponseData> {
	return axios.request({
		url: '/device/access/control/bind',
		data,
		method: 'POST'
	})
}

// 门禁列表
export function getAccessList(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/control/list',
		data,
		method: 'POST'
	})
}

export function getAccessCount(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/control/count_status',
		data,
		method: 'POST'
	})
}

export function getAccessDetail(id: string): Promise<ResponseData> {
	return axios.request({
		url: `device/access/control/${id}`,
		method: 'GET'
	})
}

export function openAccessControl(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/control/open',
		data,
		method: 'POST'
	})
}

// 解除门禁
export function unbindAccessControl(id: string): Promise<ResponseData> {
	return axios.request({
		url: `device/access/control/${id}/unbind_community`,
		method: 'POST'
	})
}

//
export function bindAccessControl(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/control/bind_community',
		method: 'POST',
		data
	})
}

// 删除门禁
export function deleteAccessControl(id: string): Promise<ResponseData> {
	return axios.request({
		url: `device/access/control/${id}`,
		method: 'DELETE'
	})
}

// 门禁授权列表
export function getAccessAuthorize(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/authorize/list',
		method: 'POST',
		data
	})
}

// 门禁授权列表
export function getAccessPassList(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/pass/list',
		method: 'POST',
		data
	})
}

export function addAccessAuthorize(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/authorize/add',
		method: 'POST',
		data
	})
}

export function updateAccessAuthorize(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/authorize/update',
		method: 'POST',
		data
	})
}

export function getAccessAuthorizeDetail(id: string): Promise<ResponseData> {
	return axios.request({
		url: `device/access/authorize/get/${id}`,
		method: 'GET'
	})
}

export function freezeAccessAuthorize(id: string, data: object): Promise<ResponseData> {
	return axios.request({
		url: `device/access/authorize/freeze/${id}`,
		data,
		method: 'POST'
	})
}

export function unfreezeAccessAuthorize(id: string, data: object): Promise<ResponseData> {
	return axios.request({
		url: `device/access/authorize/unfreeze/${id}`,
		data,
		method: 'POST'
	})
}
export function deleteAccessAuthorize(id: string, data: object): Promise<ResponseData> {
	return axios.request({
		url: `device/access/authorize/delete/${id}`,
		data,
		method: 'POST'
	})
}

export function openDoorRecord(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/opendoor/record/page',
		method: 'POST',
		data
	})
}

export function accessErrorLog(data: object): Promise<ResponseData> {
	return axios.request({
		url: 'device/access/error/log/page',
		method: 'POST',
		data
	})
}
